<template>
  <div class="admin-profile-container">
    <span v-for="color in colors" :key="color" :class="['layui-badge-dot', `bg-${color}`]"></span>
    <h2 class="admin-profile-title">安全设置</h2>
    <el-card class="admin-profile-card" shadow="always">
      <h2 class="title">密码修改</h2>
      <div class="admin-profile-info">
        <el-form ref="passwordForm" :model="passwordForm" :rules="rules" label-width="120px">
          <el-form-item label="当前密码" prop="currentPassword">
            <el-input
                v-model="passwordForm.currentPassword"
                type="password"
                placeholder="请输入当前密码"
                show-password
            ></el-input>
          </el-form-item>
          <el-form-item label="新密码" prop="newPassword">
            <el-input
                v-model="passwordForm.newPassword"
                type="password"
                placeholder="请输入新密码"
                show-password
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="submitForm">提交</el-button>
            <el-button @click="resetForm">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "AdminPasswordReset",
  data() {
    return {
      colors: ['red','orange', 'green', 'cyan', 'blue', 'gray'],
      passwordForm: {
        currentPassword: '',
        newPassword: ''
      },
      rules: {
        currentPassword: [
          {required: true, message: '请输入当前密码', trigger: 'blur'}
        ],
        newPassword: [
          {required: true, message: '请输入新密码', trigger: 'blur'},
          {min: 6, message: '密码长度不能少于6位', trigger: 'blur'}
        ]
      }
    };
  },
  methods: {
    submitForm() {
      this.$refs.passwordForm.validate((valid) => {
        if (valid) {
          this.$store.state.userType='none';
          this.$router.push('Login');
        } else {
          console.log('表单验证失败');
        }
      });
    },
    resetForm() {
      this.$refs.passwordForm.resetFields();
    }
  }
};
</script>
<style scoped>
.bg-red{
  background-color: red;
}

.bg-orange {
  background-color: #FFB900;
}

.bg-green {
  background-color: #009688;
}

.bg-cyan {
  background-color: #03A9F4;
}

.bg-blue {
  background-color: #2196F3;
}

.bg-gray {
  background-color: #9E9E9E;
}

.layui-badge-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin: 2px;
}
.layui-badge-dot:hover {
  transform: scale(1.2);
}

.admin-profile-container {
  width: 100%;
  padding: 20px;
  background-color: var(--background-color);
  color: var(--text-color);
}

.admin-profile-title {
  font-size: 1.2em;
  color: var(--primary-color);
  margin-left: 50px;
  margin-top: 20px;
}

.admin-profile-card {
  background-color: #fff;
  border: 1px solid var(--border-color);
  margin: 20px auto;
  max-width: 600px;
  padding: 20px;
}

.title {
  margin-bottom: 20px;
  font-size: 1.1em;
  color: var(--secondary-color);
}

</style>